package cn.xiu.drugstore.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.xiu.drugstore.service.DrugService;
import cn.xiu.drugstore.service.impl.DrugSerciveImpl;

public class DrugServlet extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	public void destroy() {
		super.destroy(); 
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String drugname=request.getParameter("drugname");
		DrugService ds=new DrugSerciveImpl();
		boolean flag =ds.checkDrugExists(drugname);
		if(flag){
			out.print("1");
			
		}else{
			out.print("0");
		}
		out.flush();
		out.close();
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response);
	}

	
	public void init() throws ServletException {
		
	}

}
